{
  "cells": [
    {
      "cell_type": "code",
      "source": [
        "!pip install google-search-results langchain-community langchain-core google-generativeai -q\n",
        "\n",
        "import os\n",
        "import json\n",
        "from serpapi import GoogleSearch\n",
        "import google.generativeai as genai\n",
        "from datetime import datetime"
      ],
      "metadata": {
        "id": "Ksw50tfUtcfW"
      },
      "id": "Ksw50tfUtcfW",
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "SERPAPI_API_KEY = \"Use Your API Key Here\"\n",
        "GEMINI_API_KEY = \"Use Your API Key Here\"\n",
        "\n",
        "os.environ[\"SERPAPI_API_KEY\"] = SERPAPI_API_KEY\n",
        "genai.configure(api_key=GEMINI_API_KEY)"
      ],
      "metadata": {
        "id": "ZS1xRhKstddi"
      },
      "id": "ZS1xRhKstddi",
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "class AdvancedSerpAPI:\n",
        "    def __init__(self, serpapi_key, gemini_key):\n",
        "        self.serpapi_key = serpapi_key\n",
        "        self.gemini_model = genai.GenerativeModel('gemini-1.5-flash')\n",
        "\n",
        "    def search_google(self, query, num_results=5, location=\"United States\"):\n",
        "        \"\"\"Enhanced Google search with multiple parameters\"\"\"\n",
        "        params = {\n",
        "            \"engine\": \"google\",\n",
        "            \"q\": query,\n",
        "            \"api_key\": self.serpapi_key,\n",
        "            \"num\": num_results,\n",
        "            \"location\": location,\n",
        "            \"hl\": \"en\",\n",
        "            \"gl\": \"us\"\n",
        "        }\n",
        "\n",
        "        search = GoogleSearch(params)\n",
        "        results = search.get_dict()\n",
        "        return self.extract_search_results(results)\n",
        "\n",
        "    def search_news(self, query, days_back=7):\n",
        "        \"\"\"Search for recent news articles\"\"\"\n",
        "        params = {\n",
        "            \"engine\": \"google_news\",\n",
        "            \"q\": query,\n",
        "            \"api_key\": self.serpapi_key,\n",
        "            \"gl\": \"us\",\n",
        "            \"hl\": \"en\"\n",
        "        }\n",
        "\n",
        "        search = GoogleSearch(params)\n",
        "        results = search.get_dict()\n",
        "        return self.extract_news_results(results)\n",
        "\n",
        "    def search_images(self, query, num_images=10):\n",
        "        \"\"\"Search for images with metadata\"\"\"\n",
        "        params = {\n",
        "            \"engine\": \"google_images\",\n",
        "            \"q\": query,\n",
        "            \"api_key\": self.serpapi_key,\n",
        "            \"num\": num_images\n",
        "        }\n",
        "\n",
        "        search = GoogleSearch(params)\n",
        "        results = search.get_dict()\n",
        "        return self.extract_image_results(results)\n",
        "\n",
        "    def extract_search_results(self, results):\n",
        "        \"\"\"Extract and clean search results\"\"\"\n",
        "        cleaned_results = []\n",
        "        if 'organic_results' in results:\n",
        "            for result in results['organic_results']:\n",
        "                cleaned_results.append({\n",
        "                    'title': result.get('title', ''),\n",
        "                    'link': result.get('link', ''),\n",
        "                    'snippet': result.get('snippet', ''),\n",
        "                    'position': result.get('position', 0)\n",
        "                })\n",
        "        return cleaned_results\n",
        "\n",
        "    def extract_news_results(self, results):\n",
        "        \"\"\"Extract news articles with timestamps\"\"\"\n",
        "        news_results = []\n",
        "        if 'news_results' in results:\n",
        "            for article in results['news_results']:\n",
        "                news_results.append({\n",
        "                    'title': article.get('title', ''),\n",
        "                    'link': article.get('link', ''),\n",
        "                    'snippet': article.get('snippet', ''),\n",
        "                    'date': article.get('date', ''),\n",
        "                    'source': article.get('source', '')\n",
        "                })\n",
        "        return news_results\n",
        "\n",
        "    def extract_image_results(self, results):\n",
        "        \"\"\"Extract image results with metadata\"\"\"\n",
        "        image_results = []\n",
        "        if 'images_results' in results:\n",
        "            for img in results['images_results']:\n",
        "                image_results.append({\n",
        "                    'title': img.get('title', ''),\n",
        "                    'original': img.get('original', ''),\n",
        "                    'thumbnail': img.get('thumbnail', ''),\n",
        "                    'source': img.get('source', '')\n",
        "                })\n",
        "        return image_results\n",
        "\n",
        "    def analyze_with_gemini(self, search_results, analysis_prompt):\n",
        "        \"\"\"Use Gemini Flash to analyze search results\"\"\"\n",
        "        results_text = json.dumps(search_results, indent=2)\n",
        "\n",
        "        full_prompt = f\"\"\"\n",
        "        {analysis_prompt}\n",
        "\n",
        "        Search Results Data:\n",
        "        {results_text}\n",
        "\n",
        "        Please provide a comprehensive analysis based on the search results.\n",
        "        \"\"\"\n",
        "\n",
        "        try:\n",
        "            response = self.gemini_model.generate_content(full_prompt)\n",
        "            return response.text\n",
        "        except Exception as e:\n",
        "            return f\"Gemini analysis failed: {str(e)}\"\n",
        "\n",
        "    def search_marktechpost_tutorials(self, topic=\"\", num_results=10):\n",
        "        \"\"\"Search specifically for trending tutorials from Marktechpost\"\"\"\n",
        "        queries = [\n",
        "            f\"site:marktechpost.com {topic} tutorial guide how-to 2024 2025\",\n",
        "            f\"site:marktechpost.com trending {topic} tutorial\",\n",
        "            f\"site:marktechpost.com top {topic} books frameworks\"\n",
        "        ]\n",
        "\n",
        "        all_results = []\n",
        "        for query in queries:\n",
        "            params = {\n",
        "                \"engine\": \"google\",\n",
        "                \"q\": query,\n",
        "                \"api_key\": self.serpapi_key,\n",
        "                \"num\": num_results // len(queries),\n",
        "                \"hl\": \"en\",\n",
        "                \"gl\": \"us\"\n",
        "            }\n",
        "\n",
        "            search = GoogleSearch(params)\n",
        "            results = search.get_dict()\n",
        "            extracted = self.extract_search_results(results)\n",
        "            all_results.extend(extracted)\n",
        "\n",
        "        unique_results = []\n",
        "        seen_links = set()\n",
        "        for result in all_results:\n",
        "            if result['link'] not in seen_links:\n",
        "                unique_results.append(result)\n",
        "                seen_links.add(result['link'])\n",
        "\n",
        "        return unique_results[:num_results]\n",
        "\n",
        "    def get_trending_marktechpost_content(self, categories=None):\n",
        "        \"\"\"Get trending content from Marktechpost across different categories\"\"\"\n",
        "        if categories is None:\n",
        "            categories = [\"AI\", \"LLM\", \"Machine Learning\", \"Python\", \"Tutorial\", \"Framework\"]\n",
        "\n",
        "        trending_content = {}\n",
        "\n",
        "        for category in categories:\n",
        "            print(f\"🔍 Searching for trending {category} content...\")\n",
        "            results = self.search_marktechpost_tutorials(category, num_results=5)\n",
        "            trending_content[category] = results\n",
        "            print(f\"✅ Found {len(results)} {category} tutorials\")\n",
        "\n",
        "        return trending_content\n",
        "\n",
        "    def smart_research(self, topic, research_depth=\"medium\", focus_marktechpost=True):\n",
        "        \"\"\"Intelligent research combining multiple search types with Marktechpost focus\"\"\"\n",
        "        print(f\"🔍 Starting smart research on: {topic}\")\n",
        "\n",
        "        if focus_marktechpost:\n",
        "            marktechpost_results = self.search_marktechpost_tutorials(topic, num_results=8)\n",
        "            print(f\"✅ Found {len(marktechpost_results)} Marktechpost tutorials\")\n",
        "\n",
        "            web_results = self.search_google(f\"{topic} tutorial guide\", num_results=3)\n",
        "            print(f\"✅ Found {len(web_results)} additional web results\")\n",
        "\n",
        "            all_web_results = marktechpost_results + web_results\n",
        "        else:\n",
        "            all_web_results = self.search_google(f\"{topic} overview facts\", num_results=5)\n",
        "            print(f\"✅ Found {len(all_web_results)} web results\")\n",
        "\n",
        "        news_results = self.search_news(topic)\n",
        "        print(f\"✅ Found {len(news_results)} news articles\")\n",
        "\n",
        "        analysis_prompt = f\"\"\"\n",
        "        Analyze the search results about '{topic}' with focus on Marktechpost content and provide:\n",
        "        1. Key tutorials and guides available\n",
        "        2. Trending topics and frameworks\n",
        "        3. Learning resources and books mentioned\n",
        "        4. Recent developments and updates\n",
        "        5. Practical implementation guides\n",
        "        6. Recommended learning path\n",
        "\n",
        "        Focus on actionable insights and learning resources.\n",
        "        \"\"\"\n",
        "\n",
        "        all_results = {\n",
        "            \"marktechpost_results\": marktechpost_results if focus_marktechpost else [],\n",
        "            \"web_results\": all_web_results,\n",
        "            \"news_results\": news_results,\n",
        "            \"search_topic\": topic,\n",
        "            \"timestamp\": datetime.now().isoformat()\n",
        "        }\n",
        "\n",
        "        gemini_analysis = self.analyze_with_gemini(all_results, analysis_prompt)\n",
        "\n",
        "        return {\n",
        "            \"topic\": topic,\n",
        "            \"marktechpost_tutorials\": marktechpost_results if focus_marktechpost else [],\n",
        "            \"web_results\": all_web_results,\n",
        "            \"news_results\": news_results,\n",
        "            \"ai_analysis\": gemini_analysis,\n",
        "            \"total_sources\": len(all_web_results) + len(news_results)\n",
        "        }"
      ],
      "metadata": {
        "id": "kUZR6W35tsI_"
      },
      "id": "kUZR6W35tsI_",
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "def demo_marktechpost_tutorials():\n",
        "    \"\"\"Demo specifically focused on Marktechpost tutorials\"\"\"\n",
        "\n",
        "    searcher = AdvancedSerpAPI(SERPAPI_API_KEY, GEMINI_API_KEY)\n",
        "\n",
        "    print(\"🚀 Marktechpost Trending Tutorials Finder\")\n",
        "    print(\"=\" * 50)\n",
        "\n",
        "    print(\"\\n📚 Demo 1: Trending Marktechpost Tutorials by Category\")\n",
        "    trending_content = searcher.get_trending_marktechpost_content([\n",
        "        \"LangChain\", \"ChatGPT\", \"Python\", \"AI\", \"MLOps\"\n",
        "    ])\n",
        "\n",
        "    for category, tutorials in trending_content.items():\n",
        "        print(f\"\\n🔥 Trending {category} Tutorials:\")\n",
        "        for i, tutorial in enumerate(tutorials[:3], 1):\n",
        "            print(f\"  {i}. {tutorial['title']}\")\n",
        "            print(f\"     📎 {tutorial['link']}\")\n",
        "            if tutorial['snippet']:\n",
        "                print(f\"     📝 {tutorial['snippet'][:100]}...\")\n",
        "\n",
        "    print(\"\\n🎯 Demo 2: Deep Dive - LangChain Tutorials\")\n",
        "    langchain_research = searcher.smart_research(\"LangChain\", focus_marktechpost=True)\n",
        "\n",
        "    print(f\"\\n📊 Research Summary:\")\n",
        "    print(f\"Topic: {langchain_research['topic']}\")\n",
        "    print(f\"Marktechpost Tutorials Found: {len(langchain_research['marktechpost_tutorials'])}\")\n",
        "    print(f\"Total Sources: {langchain_research['total_sources']}\")\n",
        "\n",
        "    print(f\"\\n🤖 AI Analysis Preview:\")\n",
        "    print(langchain_research['ai_analysis'][:600] + \"...\" if len(langchain_research['ai_analysis']) > 600 else langchain_research['ai_analysis'])\n",
        "\n",
        "    print(\"\\n📰 Demo 3: Latest AI Trends from Marktechpost\")\n",
        "    ai_trends = searcher.search_marktechpost_tutorials(\"AI trends 2024 2025\", num_results=5)\n",
        "\n",
        "    print(\"Recent AI trend articles:\")\n",
        "    for i, article in enumerate(ai_trends, 1):\n",
        "        print(f\"{i}. {article['title']}\")\n",
        "        print(f\"   🔗 {article['link']}\")\n",
        "\n",
        "def demo_advanced_serpapi():\n",
        "    \"\"\"Comprehensive demo of SerpAPI capabilities\"\"\"\n",
        "\n",
        "    searcher = AdvancedSerpAPI(SERPAPI_API_KEY, GEMINI_API_KEY)\n",
        "\n",
        "    print(\"🚀 Advanced SerpAPI Tutorial with Gemini Flash\")\n",
        "    print(\"=\" * 50)\n",
        "\n",
        "    print(\"\\n📊 Demo 1: Smart Research on AI Technology\")\n",
        "    research_results = searcher.smart_research(\"artificial intelligence 2024 trends\")\n",
        "\n",
        "    print(f\"\\n🔍 Research Summary:\")\n",
        "    print(f\"Topic: {research_results['topic']}\")\n",
        "    print(f\"Total Sources: {research_results['total_sources']}\")\n",
        "\n",
        "    print(f\"\\n🤖 AI Analysis Preview:\")\n",
        "    print(research_results['ai_analysis'][:500] + \"...\" if len(research_results['ai_analysis']) > 500 else research_results['ai_analysis'])\n",
        "\n",
        "    print(\"\\n📰 Demo 2: Recent News Search\")\n",
        "    tech_news = searcher.search_news(\"technology breakthrough\", days_back=7)\n",
        "\n",
        "    print(f\"Found {len(tech_news)} recent tech news articles:\")\n",
        "    for i, article in enumerate(tech_news[:3], 1):\n",
        "        print(f\"{i}. {article['title'][:80]}...\")\n",
        "        print(f\"   Source: {article['source']} | Date: {article['date']}\")\n",
        "\n",
        "    print(\"\\n🖼️  Demo 3: Image Search\")\n",
        "    space_images = searcher.search_images(\"space exploration 2024\", num_images=5)\n",
        "\n",
        "    print(f\"Found {len(space_images)} space-related images:\")\n",
        "    for i, img in enumerate(space_images[:3], 1):\n",
        "        print(f\"{i}. {img['title'][:60]}...\")\n",
        "        print(f\"   Source: {img['source']}\")"
      ],
      "metadata": {
        "id": "IZx9hq-stwPE"
      },
      "id": "IZx9hq-stwPE",
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "if __name__ == \"__main__\":\n",
        "    if SERPAPI_API_KEY == \"your_serpapi_key_here\" or GEMINI_API_KEY == \"your_gemini_key_here\":\n",
        "        print(\"⚠️  Please set your API keys before running the demo!\")\n",
        "        print(\"1. Get SerpAPI key from: https://serpapi.com\")\n",
        "        print(\"2. Get Gemini API key from: https://makersuite.google.com\")\n",
        "    else:\n",
        "        print(\"🎯 Running Marktechpost-focused demo...\")\n",
        "        demo_marktechpost_tutorials()\n",
        "\n",
        "        print(\"\\n\" + \"=\"*50)\n",
        "        print(\"🌟 Running general demo...\")\n",
        "        demo_advanced_serpapi()\n",
        "\n",
        "def compare_search_engines(query, engines=['google', 'bing', 'duckduckgo']):\n",
        "    \"\"\"Compare results across different search engines\"\"\"\n",
        "    results = {}\n",
        "\n",
        "    for engine in engines:\n",
        "        params = {\n",
        "            \"engine\": engine,\n",
        "            \"q\": query,\n",
        "            \"api_key\": SERPAPI_API_KEY\n",
        "        }\n",
        "\n",
        "        try:\n",
        "            search = GoogleSearch(params)\n",
        "            results[engine] = search.get_dict()\n",
        "        except Exception as e:\n",
        "            results[engine] = {\"error\": str(e)}\n",
        "\n",
        "    return results\n",
        "\n",
        "def trending_searches(location=\"United States\"):\n",
        "    \"\"\"Get trending searches\"\"\"\n",
        "    params = {\n",
        "        \"engine\": \"google_trends_trending_now\",\n",
        "        \"api_key\": SERPAPI_API_KEY,\n",
        "        \"geo\": location\n",
        "    }\n",
        "\n",
        "    search = GoogleSearch(params)\n",
        "    return search.get_dict()\n",
        "\n",
        "print(\"✅ Advanced SerpAPI Tutorial with Marktechpost Focus loaded successfully!\")\n",
        "print(\"🔑 Remember to set your API keys before running demos\")\n",
        "print(\"📚 New Functions: search_marktechpost_tutorials, get_trending_marktechpost_content\")\n",
        "print(\"🎯 Marktechpost-specific features: LangChain, ChatGPT, Python, AI, MLOps tutorials\")\n",
        "\n",
        "print(\"\\n🚀 Quick Start Examples:\")\n",
        "print(\"searcher = AdvancedSerpAPI(SERPAPI_API_KEY, GEMINI_API_KEY)\")\n",
        "print(\"langchain_tutorials = searcher.search_marktechpost_tutorials('LangChain')\")\n",
        "print(\"trending_ai = searcher.get_trending_marktechpost_content(['AI', 'Python'])\")\n",
        "print(\"research = searcher.smart_research('ChatGPT', focus_marktechpost=True)\")"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000
        },
        "id": "WzWfw10XPlyb",
        "outputId": "d9bba190-5208-40d6-9c30-cf51be7a3907"
      },
      "id": "WzWfw10XPlyb",
      "execution_count": 10,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "🎯 Running Marktechpost-focused demo...\n",
            "🚀 Marktechpost Trending Tutorials Finder\n",
            "==================================================\n",
            "\n",
            "📚 Demo 1: Trending Marktechpost Tutorials by Category\n",
            "🔍 Searching for trending LangChain content...\n",
            "✅ Found 3 LangChain tutorials\n",
            "🔍 Searching for trending ChatGPT content...\n",
            "✅ Found 3 ChatGPT tutorials\n",
            "🔍 Searching for trending Python content...\n",
            "✅ Found 3 Python tutorials\n",
            "🔍 Searching for trending AI content...\n",
            "✅ Found 3 AI tutorials\n",
            "🔍 Searching for trending MLOps content...\n",
            "✅ Found 2 MLOps tutorials\n",
            "\n",
            "🔥 Trending LangChain Tutorials:\n",
            "  1. How to Use Langchain? Step-by-Step Guide\n",
            "     📎 https://www.marktechpost.com/2023/12/16/how-to-use-langchain-step-by-step-guide/\n",
            "     📝 Step1: Setup · Step2: LLMs · Step 3: LangChain Prompt Templates · Step 4: Chains · Step 5: Agents an...\n",
            "  2. How to Build a Powerful and Intelligent Question ...\n",
            "     📎 https://www.marktechpost.com/2025/05/17/how-to-build-a-powerful-and-intelligent-question-answering-system-by-using-tavily-search-api-chroma-google-gemini-llms-and-the-langchain-framework/\n",
            "     📝 In this tutorial, we demonstrate how to build a powerful and intelligent question-answering system b...\n",
            "  3. Top LangChain Books to Read in 2024\n",
            "     📎 https://www.marktechpost.com/2024/04/16/top-langchain-books-to-read-in-2024/\n",
            "     📝 Top LangChain Books to Read in 2024 · Quick Start Guide to Large Language Models · Introduction to G...\n",
            "\n",
            "🔥 Trending ChatGPT Tutorials:\n",
            "  1. OpenAI's ChatGPT Canvas Tutorial and Use Cases\n",
            "     📎 https://www.marktechpost.com/2024/10/05/openais-chatgpt-canvas-tutorial-and-use-cases-coding-customization-and-visualizing-tesla-stock-data/\n",
            "     📝 Step 1: Go to the ChatGPT platform (Premium) version and choose GPT-4o with Canvas · Step 2: Now ask...\n",
            "  2. How to Create a Market Research Report Using ChatGPT ...\n",
            "     📎 https://aiagent.marktechpost.com/post/how-to-create-a-market-research-report-using-chatgpt-deep-research\n",
            "     📝 ChatGPT's Deep Research is an AI agent that offers a shortcut through this maze, rapidly gathering d...\n",
            "  3. Top ChatGPT Books to Read in 2024\n",
            "     📎 https://www.marktechpost.com/2024/04/01/top-chatgpt-books-to-read-in-2024/\n",
            "     📝 In 2024, ChatGPT is still one of the most trending topics, and this article lists the top ChatGPT bo...\n",
            "\n",
            "🔥 Trending Python Tutorials:\n",
            "  1. A Beginners Guide to Using Visual Studio Code for Python\n",
            "     📎 https://www.marktechpost.com/2025/03/29/a-beginners-guide-to-using-visual-studio-code-for-python/\n",
            "     📝 In this tutorial, we explored how to set up VSCode for Python development from scratch. We began by ...\n",
            "  2. Web Scraping, NLP (Sentiment Analysis & Topic Modeling) ...\n",
            "     📎 https://www.marktechpost.com/2025/03/09/a-step-by-step-guide-to-build-a-trend-finder-tool-with-python-web-scraping-nlp-sentiment-analysis-topic-modeling-and-word-cloud-visualization/\n",
            "     📝 Learn how to scrape publicly accessible websites, apply powerful NLP (Natural Language Processing) t...\n",
            "  3. Top Python Programming Books to Read in 2024\n",
            "     📎 https://www.marktechpost.com/2024/04/02/top-python-programming-books-to-read-in-2024/\n",
            "     📝 “Python Crash Course” is one of the most popular guides to the Python language. It starts with basic...\n",
            "\n",
            "🔥 Trending AI Tutorials:\n",
            "  1. A Step-by-Step Coding Guide to Building an Iterative AI ...\n",
            "     📎 https://www.marktechpost.com/2025/06/05/a-step-by-step-coding-guide-to-building-an-iterative-ai-workflow-agent-using-langgraph-and-gemini/\n",
            "     📝 In this tutorial, we demonstrate how to build a multi-step, intelligent query-handling agent using L...\n",
            "  2. A Coding Guide for Building a Self-Improving AI Agent ...\n",
            "     📎 https://www.marktechpost.com/2025/05/29/a-coding-guide-for-building-a-self-improving-ai-agent-using-googles-gemini-api-with-intelligent-adaptation-features/\n",
            "     📝 In this tutorial, we will explore how to create a sophisticated Self-Improving AI Agent using Google...\n",
            "  3. Top Artificial Intelligence AI Books to Read in 2025\n",
            "     📎 https://www.marktechpost.com/2025/06/05/top-artificial-intelligence-books-to-read-in-2025/\n",
            "     📝 AI Superpowers: China, Silicon Valley, and the New World Order. The author of this book explains the...\n",
            "\n",
            "🔥 Trending MLOps Tutorials:\n",
            "  1. Top MLOps Books to Read in 2024\n",
            "     📎 https://www.marktechpost.com/2024/04/07/top-mlops-books-to-read-in-2024/\n",
            "     📝 This book is a comprehensive guide to managing the lifecycle of a machine learning project, from dev...\n",
            "  2. Top Artificial Intelligence (AI) Trends to Watch in 2023\n",
            "     📎 https://www.marktechpost.com/2023/01/07/top-artificial-intelligence-ai-trends-to-watch-in-2023/\n",
            "     📝 1. Voice and language-driven intelligence · 2. Ethical and Explainable AI · 3. AI-powered cybersecur...\n",
            "\n",
            "🎯 Demo 2: Deep Dive - LangChain Tutorials\n",
            "🔍 Starting smart research on: LangChain\n",
            "✅ Found 5 Marktechpost tutorials\n",
            "✅ Found 2 additional web results\n",
            "✅ Found 100 news articles\n",
            "\n",
            "📊 Research Summary:\n",
            "Topic: LangChain\n",
            "Marktechpost Tutorials Found: 5\n",
            "Total Sources: 107\n",
            "\n",
            "🤖 AI Analysis Preview:\n",
            "## LangChain Analysis: Focus on Marktechpost and Actionable Insights\n",
            "\n",
            "This analysis focuses on the provided search results, emphasizing Marktechpost content and actionable learning resources for LangChain.\n",
            "\n",
            "**1. Key Tutorials and Guides Available (Marktechpost):**\n",
            "\n",
            "Marktechpost provides numerous step-by-step tutorials focusing on practical LangChain applications:\n",
            "\n",
            "* **\"How to Use Langchain? Step-by-Step Guide\":** A foundational tutorial covering setup, LLMs, prompt templates, chains, agents, tools, memory, and document loaders. This is an excellent starting point.\n",
            "* **\"Step-by-Step Guide to Bu...\n",
            "\n",
            "📰 Demo 3: Latest AI Trends from Marktechpost\n",
            "Recent AI trend articles:\n",
            "1. BOND 2025 AI Trends Report Shows AI Ecosystem ...\n",
            "   🔗 https://www.marktechpost.com/2025/05/31/bond-2025-ai-trends-report-shows-ai-ecosystem-growing-faster-than-ever-with-explosive-user-and-developer-adoption/\n",
            "2. Top Artificial Intelligence AI Books to Read in 2025\n",
            "   🔗 https://www.marktechpost.com/2025/06/05/top-artificial-intelligence-books-to-read-in-2025/\n",
            "\n",
            "==================================================\n",
            "🌟 Running general demo...\n",
            "🚀 Advanced SerpAPI Tutorial with Gemini Flash\n",
            "==================================================\n",
            "\n",
            "📊 Demo 1: Smart Research on AI Technology\n",
            "🔍 Starting smart research on: artificial intelligence 2024 trends\n",
            "✅ Found 5 Marktechpost tutorials\n",
            "✅ Found 2 additional web results\n",
            "✅ Found 100 news articles\n",
            "\n",
            "🔍 Research Summary:\n",
            "Topic: artificial intelligence 2024 trends\n",
            "Total Sources: 107\n",
            "\n",
            "🤖 AI Analysis Preview:\n",
            "## Analysis of Search Results: Artificial Intelligence 2024 Trends (MarkTechPost Focus)\n",
            "\n",
            "This analysis focuses on the provided search results, prioritizing insights from MarkTechPost content and incorporating relevant information from other sources.  The data includes results from 2024 and into 2025, reflecting a forward-looking perspective on AI trends.\n",
            "\n",
            "**1. Key Tutorials and Guides Available:**\n",
            "\n",
            "The provided MarkTechPost data doesn't directly link to tutorials or guides.  However, the mention...\n",
            "\n",
            "📰 Demo 2: Recent News Search\n",
            "Found 100 recent tech news articles:\n",
            "1. Breakthrough soft robotics could redefine artificial heart technology...\n",
            "   Source: {'name': 'News-Medical', 'icon': 'https://encrypted-tbn3.gstatic.com/faviconV2?url=https://www.news-medical.net&client=NEWS_360&size=96&type=FAVICON&fallback_opts=TYPE,SIZE,URL', 'authors': ['Sanchari Sinha Dutta']} | Date: 06/06/2025, 01:37 AM, +0000 UTC\n",
            "2. U.S. Navy Highlights Breakthrough UUV Operations Using HII-Built Technologies...\n",
            "   Source: {'name': 'HII', 'icon': 'https://encrypted-tbn2.gstatic.com/faviconV2?url=https://hii.com&client=NEWS_360&size=96&type=FAVICON&fallback_opts=TYPE,SIZE,URL'} | Date: 06/05/2025, 05:43 PM, +0000 UTC\n",
            "3. Connecting the DNA dots: How new technology led to breakthrough in Morgan Nick c...\n",
            "   Source: {'name': 'Yahoo', 'icon': 'https://encrypted-tbn1.gstatic.com/faviconV2?url=https://www.yahoo.com&client=NEWS_360&size=96&type=FAVICON&fallback_opts=TYPE,SIZE,URL', 'authors': ['Doug Warner']} | Date: 06/06/2025, 02:28 AM, +0000 UTC\n",
            "\n",
            "🖼️  Demo 3: Image Search\n",
            "Found 100 space-related images:\n",
            "1. Space Exploration in 2024: Key Missions ......\n",
            "   Source: CivilsDaily\n",
            "2. The 21 most exciting space missions of 2024...\n",
            "   Source: Freethink\n",
            "3. 6 space missions to look forward to in ......\n",
            "   Source: PBS\n",
            "✅ Advanced SerpAPI Tutorial with Marktechpost Focus loaded successfully!\n",
            "🔑 Remember to set your API keys before running demos\n",
            "📚 New Functions: search_marktechpost_tutorials, get_trending_marktechpost_content\n",
            "🎯 Marktechpost-specific features: LangChain, ChatGPT, Python, AI, MLOps tutorials\n",
            "\n",
            "🚀 Quick Start Examples:\n",
            "searcher = AdvancedSerpAPI(SERPAPI_API_KEY, GEMINI_API_KEY)\n",
            "langchain_tutorials = searcher.search_marktechpost_tutorials('LangChain')\n",
            "trending_ai = searcher.get_trending_marktechpost_content(['AI', 'Python'])\n",
            "research = searcher.smart_research('ChatGPT', focus_marktechpost=True)\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [],
      "metadata": {
        "id": "jb17ix93tasi"
      },
      "id": "jb17ix93tasi",
      "execution_count": null,
      "outputs": []
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3 (ipykernel)",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.10.9"
    },
    "colab": {
      "provenance": []
    }
  },
  "nbformat": 4,
  "nbformat_minor": 5
}